﻿package {
	import flash.display.*;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.net.*;
	
	import mx.controls.*;
	import mx.controls.listClasses.*;
	import mx.events.ResizeEvent;
	
	public class FunctionRenderer extends ListItemRenderer {
		
		public var bt_del:Sprite;
		public function FunctionRenderer() {
			super();
			init();
			this.addEventListener(ResizeEvent.RESIZE, resizeHd);
		}
		private function init():void {
			bt_del = new Sprite();
			bt_del.alpha = 0.3;
			bt_del.buttonMode = true;
			bt_del.addChild(new IconDel());
			bt_del.addEventListener(MouseEvent.MOUSE_OVER, overHd);
			bt_del.addEventListener(MouseEvent.MOUSE_OUT, outHd);
			bt_del.addEventListener(MouseEvent.CLICK, delHd);
			addChild(bt_del);
		}
		private function overHd(e:Event):void {
			e.target.alpha = 1;
		}
		private function outHd(e:Event):void {
			e.target.alpha = 0.3;
		}
		private function resizeHd(e:Event):void {
    		layout()
    	}
    	private function layout():void {
    		bt_del.x = this.width - bt_del.width - 2;
    		bt_del.y = (this.height - bt_del.height)*0.5;
    		this.setChildIndex(bt_del,this.numChildren - 1); 
    	}
    	private function delHd(e:Event):void {
    		var list:List = listData.owner as List;
    		var delEvent:Event = new Event("itemdel");
    		list.dispatchEvent(delEvent);
    	}
    	//override public function set listData(d:BaseListData):void {
      		//super.listData = d;      		
    	//}

	}
}